<template>
  <div>
    <div v-show="type == 'first'">
      <FilterTable
        ref="firsttable"
        :fetchapi="fetchApi1"
        :columns="columns1"
        :params="fetchParams1"
        :datakey="'rows'"
        :isSelectColumn="false"
        :onColumnsChange="columns1 => (this.columns1 = columns1)"
        :height="130"
        columnsRef="zjwxlssettlementTables1"
      ></FilterTable>
    </div>
    <div v-show="type == 'second'">
      <FilterTable
        ref="secondtable"
        :columns="columns2"
        :fetchapi="fetchApi2"
        :params="fetchParams1"
        :datakey="'rows'"
        :isSelectColumn="false"
        :onColumnsChange="columns2 => (this.columns2 = columns2)"
        :height="130"
        columnsRef="zjwxlssettlementTables2"
      ></FilterTable>
    </div>
    <div v-show="type == 'third'">
      <FilterTable
        ref="thirdtable"
        :columns="columns3"
        :fetchapi="fetchApi3"
        :params="fetchParams1"
        :datakey="'rows'"
        :isSelectColumn="false"
        :onColumnsChange="columns3 => (this.columns3 = columns3)"
        :height="130"
        columnsRef="zjwxlssettlementTables3"
      ></FilterTable>
    </div>
    <div v-show="type == 'fourth'">
      <FilterTable
        ref="fourthtable"
        :columns="columns4"
        :params="fetchParams1"
        :fetchapi="fetchApi4"
        :datakey="'rows'"
        :isSelectColumn="false"
        :onColumnsChange="columns4 => (this.columns4 = columns4)"
        :height="130"
        columnsRef="zjwxlssettlementTables4"
      ></FilterTable>
    </div>
    <BaseDialog
      :visible.sync="exchangingVisible"
      title="派工情况"
      destroyOnClose
      :containerStyle="{ height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px' }"
    >
      <exchanging :getdata="exchangingData" @close="closepop"></exchanging>
    </BaseDialog>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import exchanging from './exchanging.vue';
import { getWXXM, getWXCL, getXSCL, getFJXM } from '@/api/repair/business/customer/history';
export default {
  name: 'zjsettlementTables',
  components: {
    exchanging
  },
  mixins: [dictionary],
  props: ['type', 'getdata'],
  data() {
    this.firsttable = null;
    this.secondtable = null;
    this.thirdtable = null;
    this.fourthtable = null;
    return {
      fetchParams1: { RO_NO: this.getdata.RO_NO },
      fetchParams2: { RO_NO: this.getdata.RO_NO },
      fetchParams3: { RO_NO: this.getdata.RO_NO },
      fetchParams4: { RO_NO: this.getdata.RO_NO },
      columns1: this.createTable1(),
      columns2: this.createTable2(),
      columns3: this.createTable3(),
      columns4: this.createTable4(),
      fetchApi1: getWXXM,
      fetchApi2: getWXCL,
      fetchApi3: getXSCL,
      fetchApi4: getFJXM,
      exchangingVisible: false,
      exchangingData: {
        RO_NO: this.getdata.RO_NO,
        ASC_SHORTNAME: this.getdata.ASC_SHORTNAME,
        projectName: '',
        assignLabourHour: '',
        troubleDesc: ''
      }
    };
  },
  created() {},
  methods: {
    createTable1() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 70,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_CODE',
          sorter: true,
          filter: true
        },
        {
          title: '故障原因',
          dataIndex: 'TROUBLE_CAUSE',
          sorter: true,
          filter: true
        },
        {
          title: '项目维修类型',
          dataIndex: 'REPAIR_TYPE_CODE',
          sorter: true,
          filter: true
        },
        {
          title: '项目代码',
          dataIndex: 'LABOUR_CODEF',
          sorter: true,
          filter: true
        },
        {
          title: '项目名称',
          dataIndex: 'LABOUR_NAME',
          width: 200,
          sorter: true,
          filter: true
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          sorter: true,
          filter: true
        },
        {
          title: '派工工时',
          dataIndex: 'ASSIGN_LABOUR_HOUR',
          sorter: true,
          filter: true
        },
        {
          title: '标准工时',
          dataIndex: 'STD_LABOUR_HOUR',
          sorter: true,
          filter: true
        },
        {
          title: '索赔工时',
          dataIndex: 'CLAIM_LABOUR',
          sorter: true,
          filter: true
        },
        {
          title: '优惠金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          sorter: true,
          filter: true
        },
        {
          title: '折扣率',
          dataIndex: 'DISCOUNT',
          sorter: true,
          filter: true,

          editType: 'number'
        },
        {
          title: '实收金额',
          dataIndex: 'RECEIVE_AMOUNT',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '工时单价',
          dataIndex: 'LABOUR_PRICE',
          sorter: true,
          filter: true,

          editType: 'number'
        },
        {
          title: '工种',
          dataIndex: 'WORKER_TYPE_CODE',
          minWidth: 120,
          sorter: true,
          filter: true
        },
        {
          title: '责任技师',
          dataIndex: 'TECHNICIAN',
          sorter: true,
          filter: true
        },
        {
          title: '是否派工',
          dataIndex: 'ASSIGN_TAG',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.DOWN_TAG, '1004')}</span>;
          }
        },
        {
          title: '是否增项',
          dataIndex: 'IS_ADDITION',
          sorter: true,
          filter: true,
          filterType: 'checkbox',
          filterItems: [],
          filterItems: this.createDictList('1004'),
          render: props => {
            return <span>{this.createDictText(props.row.IS_ADDITION, '1004')}</span>;
          }
        },
        {
          title: '是否委外',
          dataIndex: 'CONSIGN_EXTERIOR',
          sorter: true,
          render: props => {
            let val = props.row.CONSIGN_EXTERIOR === '1' ? true : false;
            return <el-checkbox value={val} onInput={val => (props.row.CONSIGN_EXTERIOR = val ? '1' : '0')}></el-checkbox>;
          }
        },
        {
          title: '是否不修',
          dataIndex: 'NEEDLESS_REPAIR',
          sorter: true,
          filter: true,
          render: props => {
            let val = props.row.NEEDLESS_REPAIR === '1' ? true : false;
            return <el-checkbox value={val} onInput={val => (props.row.NEEDLESS_REPAIR = val ? '1' : '0')}></el-checkbox>;
          }
        },
        {
          title: '不修原因',
          dataIndex: 'REASON',
          sorter: true,
          filter: true
        },
        {
          title: '是否预拣',
          dataIndex: 'PRE_CHECK',
          sorter: true,
          render: props => {
            let val = props.row.PRE_CHECK === '1' ? true : false;
            return <el-checkbox value={val} onInput={val => (props.row.PRE_CHECK = val ? '1' : '0')}></el-checkbox>;
          }
        },
        {
          title: '是否内返',
          dataIndex: 'INTER_RETURN',
          sorter: true,
          render: props => {
            let val = props.row.INTER_RETURN === '1' ? true : false;
            return <el-checkbox value={val} onInput={val => (props.row.INTER_RETURN = val ? '1' : '0')}></el-checkbox>;
          }
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE',
          sorter: true,
          filter: true
        },
        {
          title: '检查结果',
          dataIndex: 'TROUBLE_DESC',
          sorter: true,
          filter: true
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          minWidth: 200,
          sorter: true,
          filter: true
        },
        {
          title: '组合代码',
          dataIndex: 'PACKAGE_CODE',
          sorter: true,
          filter: true,
          filterType: 'input'
        },
        {
          title: '项目车型组',
          dataIndex: 'MODEL_LABOUR_CODE',
          minWidth: 200,
          sorter: true,
          filter: true
        },
        {
          title: '钣喷面积',
          dataIndex: 'SPRAY_AREA',
          sorter: true,
          filter: true
        },
        {
          title: '故障部位',
          dataIndex: 'POS_NAME',
          sorter: true,
          filter: true
        },
        {
          title: '故障',
          dataIndex: 'APP_NAME',
          sorter: true,
          filter: true
        }
      ];
    },
    createTable2() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_NAME}</span>;
          }
        },
        {
          title: '维修类型',
          dataIndex: 'REPAIR_TYPE_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REPAIR_TYPE_NAME}</span>;
          }
        },
        {
          title: '故障原因',
          dataIndex: 'TROUBLE_CAUSE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.TROUBLE_CAUSE}</span>;
          }
        },
        {
          title: '维修项目代码',
          dataIndex: 'LABOUR_CODEF',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_CODEF}</span>;
          }
        },
        {
          title: '维修项目名称',
          dataIndex: 'LABOUR_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_NAME}</span>;
          }
        },
        {
          title: '组合代码',
          dataIndex: 'PACKAGE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PACKAGE_CODE}</span>;
          }
        },
        {
          title: '维修车型分组代码',
          dataIndex: 'MODEL_LABOUR_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MODEL_LABOUR_CODE}</span>;
          }
        },
        {
          title: '工时单价',
          dataIndex: 'LABOUR_PRICE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_PRICE}</span>;
          }
        },
        {
          title: '标准工时',
          dataIndex: 'STD_LABOUR_HOUR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.STD_LABOUR_HOUR}</span>;
          }
        },
        {
          title: '工时费',
          dataIndex: 'LABOUR_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.LABOUR_AMOUNT}</span>;
          }
        },
        {
          title: '派工工时',
          dataIndex: 'ASSIGN_LABOUR_HOUR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ASSIGN_LABOUR_HOUR}</span>;
          }
        },
        {
          title: '优惠金额',
          dataIndex: 'DISCOUNT_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.DISCOUNT_AMOUNT}</span>;
          }
        },
        {
          title: '折旧率',
          dataIndex: 'DISCOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.DISCOUNT}</span>;
          }
        },
        {
          title: '实收金额',
          dataIndex: 'RECEIVE_AMOUNT',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.RECEIVE_AMOUNT}</span>;
          }
        },
        {
          title: '工种',
          dataIndex: 'WORKER_TYPE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.WORKER_TYPE_CODE}</span>;
          }
        },
        {
          title: '派工标志',
          dataIndex: 'ASSIGN_TAG',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.ASSIGN_TAG, '1278')}</span>;
          }
        },
        {
          title: '是否委外',
          dataIndex: 'CONSIGN_EXTERIOR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.CONSIGN_EXTERIOR, '1278')}</span>;
          }
        },
        {
          title: '是否不修',
          dataIndex: 'NEEDLESS_REPAIR',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.NEEDLESS_REPAIR, '1278')}</span>;
          }
        },
        {
          title: '责任技师',
          dataIndex: 'TECHNICIAN_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.TECHNICIAN_NAME, '1278')}</span>;
          }
        },
        {
          title: '是否预检',
          dataIndex: 'PRE_CHECK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.PRE_CHECK, '1278')}</span>;
          }
        },
        {
          title: '是否内返',
          dataIndex: 'INTER_RETURN',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.INTER_RETURN, '1278')}</span>;
          }
        },
        {
          title: '活动编号',
          dataIndex: 'ACTIVITY_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ACTIVITY_CODE}</span>;
          }
        },
        {
          title: '检查结果',
          dataIndex: 'TROUBLE_DESC',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.TROUBLE_DESC}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REMARK}</span>;
          }
        }
      ];
    },
    createTable3() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_CODE}</span>;
          }
        },
        {
          title: '仓库代码',
          dataIndex: 'STORAGE_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.STORAGE_CODE}</span>;
          }
        },
        {
          title: '备件代码',
          dataIndex: 'PART_NO',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PART_NO}</span>;
          }
        },
        {
          title: '备件名称',
          dataIndex: 'PART_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PART_NAME}</span>;
          }
        },
        {
          title: '计量单位',
          dataIndex: 'UNIT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.UNIT_CODE}</span>;
          }
        },
        {
          title: '备件销售数量',
          dataIndex: 'PART_QUANTITY',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.PART_QUANTITY}</span>;
          }
        },
        {
          title: '是否入账',
          dataIndex: 'IS_FINISHED',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{this.createDictText(props.row.IS_FINISHED, '1278')}</span>;
          }
        }
      ];
    },
    createTable4() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        {
          title: '收费类别',
          dataIndex: 'MANAGE_SORT_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.MANAGE_SORT_CODE}</span>;
          }
        },
        {
          title: '收费区分',
          dataIndex: 'CHARGE_PARTITION_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.CHARGE_PARTITION_NAME}</span>;
          }
        },
        {
          title: '附加项目代码',
          dataIndex: 'ADD_ITEM_CODE',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ADD_ITEM_CODE}</span>;
          }
        },
        {
          title: '附加项目名称',
          dataIndex: 'ADD_ITEM_NAME',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.ADD_ITEM_NAME}</span>;
          }
        },
        {
          title: '备注',
          dataIndex: 'REMARK',
          sorter: true,
          filter: true,
          render: props => {
            return <span>{props.row.REMARK}</span>;
          }
        }
      ];
    },
    closepop(val) {
      this.exchangingVisible = false;
    },
    detailFun(data) {
      this.exchangingData.projectName = data.row.LABOUR_NAME;
      this.exchangingData.assignLabourHour = data.row.ASSIGN_LABOUR_HOUR;
      this.exchangingData.troubleDesc = data.row.TROUBLE_DESC;

      this.exchangingVisible = true;
    }
  }
};
</script>
